package com.demo.controller;


import com.demo.bean.Student;
import com.demo.service.impl.CacheTestOneImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: lixiaodong
 * @Description:  springboot缓存使用
 * @Date: 2022/9/15 15:14
 * @Parms: 
 * @ReturnType: 
 */
@Api(tags = "springboot缓存使用")
@RestController
public class CacheTestController {
    @Autowired
    private CacheTestOneImpl cacheTestOne;

    @ApiOperation(value = "springboot缓存使用,添加", notes = "springboot缓存使用,添加")
    @PutMapping("test1/{id}")
    public String test1(@PathVariable Integer id, @RequestBody Student student){
        cacheTestOne.putCache(id,student);
        return "插入缓存";
    }

    @ApiOperation(value = "springboot缓存使用,取出", notes = "springboot缓存使用,去除")
    @GetMapping("test2/{id}")
    public String test2(@PathVariable Integer id) {
        Student student = cacheTestOne.gainCache(id);
        return student.toString();
    }
}
